import cv2
import os

base_path ="/root/workspace/Pro/smart_car/res/samples/train/"
pic_name_list = os.listdir(base_path)
pic_idx = 1
pic_n = len(pic_name_list)
if pic_n==0:
    print("no picture")
else:
    while 1:
        if pic_idx < 1:
            pic_idx = 1
        elif pic_idx > pic_n:
            pic_idx = pic_n
        pic_name = f"{pic_idx}.jpg"
        pic_path = os.path.join(base_path,pic_name)
        img = cv2.imread(pic_path)
        cv2.imshow("img",img)
        key =  cv2.waitKey(0)
        if key == ord('a'):
            pic_idx -= 1
        elif key == ord('d'):
            pic_idx += 1
        elif key == 27:
            break

    cv2.destroyAllWindows()
    print("end show_history")
